/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apt;

import java.util.Scanner;

/**
 *
 * @author lhminh
 */
public class PhanSo {
    private int tuSo;
    private int mauSo;
    
    public PhanSo() {
        tuSo = 0;
        mauSo = 1;
    }
    
    public PhanSo(int tuSo, int mauSo) {
        this.tuSo = tuSo;
        this.mauSo = mauSo;
    }
    
    public PhanSo(PhanSo p) {
        this.tuSo = p.tuSo;
        this.mauSo = p.mauSo;
    }
    
    public void nhap() {
        Scanner s = new Scanner(System.in);
        System.out.print("Nhap tu so: ");
        this.tuSo = s.nextInt();
        System.out.print("Nhap mau so: ");
        this.mauSo = s.nextInt();
    }
    
    public void xuat() {
        System.out.print(this.tuSo + "/" + this.mauSo);
    }
    
    public PhanSo tong(PhanSo ps) {
        PhanSo kq = new PhanSo();
        kq.tuSo = this.tuSo*ps.mauSo + this.mauSo*ps.tuSo;
        kq.mauSo = this.mauSo * ps.mauSo;
        return kq;
    }
}
